package com.cims.dao.customer;

import com.cims.common.exception.DaoException;
import com.cims.common.vo.Customer;
import com.cims.common.vo.User;
import com.cims.dao.hibernate.HibernateUtil;

public class CustomerDAOImpl implements CustomerDAO{

	@Override
	public boolean register(Customer customer) throws DaoException{
		return HibernateUtil.insertVo(customer);
	}

	@Override
	public boolean authenticateCustomer(String username, String password){
		if(HibernateUtil.findOne(User.class, "from Customer where username='" + username + "' and password='" + password + "'") != null){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public Customer getCustomerDetail(String username){
		return HibernateUtil.findOne(Customer.class, "from Customer where username='" + username + "'");
	}

}
